package lab03.test05;

import jdk.internal.util.xml.impl.Input;

import java.io.*;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Scanner;

public class Test05 {
    public static void main(String[] args) throws IOException {

        System.out.println("请输入你要加密的字符串：");
        Scanner sc = new Scanner(System.in);
        String string = new String();
        string = sc.next();


        File fileR = new File("D:\\java实验\\lab03test05.txt");
        File fileW = new File("D:\\java实验\\lab03test05(2).txt");


         /*将字符串拆分为字符到数组
        *创建一个字符串数组
        * 缓存数组
         */
        char chars[] = string.toCharArray();
        char cStr[] = new char[string.length()];

        for (int i = 0; i < string.length(); i++) {
            cStr[i] = (char) ((int) chars[i] + 1);
        }
        System.out.println(cStr);

        try {
            FileReader fileReader = new FileReader(fileR);
            FileWriter fileWriter = new FileWriter(fileW);
            fileWriter.write(Arrays.toString(chars));

            int data = 0;
            while ((data = fileReader.read()) != -1) {
                System.out.print((char) data+" ");
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
